<template>
  <div class="projectManage-search">
    <p class='search-wrap'>

      <span>
        <label>假种方案名称:</label>
        <el-input
          v-model.trim="searchVal"
          style='width:240px'
          @keyup.enter.native.stop ='handleSeach'
        >
          <el-button @click.stop='handleSeach' slot="append">查询</el-button>
        </el-input>
      </span>
     
      <a class="btn" @click.stop="handleAdd">
        <i class="fa fa-plus"></i>新增
      </a>
    </p>

  </div>
</template>

<script>
import { MessageBox, Message } from 'element-ui'
import Bus from './bus'
export default {
 
  data () {
    return {
      searchVal: ''
    }
  },
  methods: {

    handleSeach () {

      Bus.$emit('searchVal',this.searchVal)
      Bus.$emit('refresh',Math.random())
     
    },

    handleAdd () {
      MessageBox.prompt('请输入假种方案名称', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /\S/,
        inputErrorMessage: '假种方案名称不能为空'
      }).then(({ value }) => {

        const params = {
          name: value
        }

        this.Axios
          .Post('/wfConfLeaveType/addLeaveType', params)
          .then((res) => {
            const type = res.data.status == 1 ? 'success' : 'error'
            Message({
              type,
              message: res.data.message
            })

            res.data.status == 1 && Bus.$emit('refresh', Math.random())
          })
      }).catch(() => {
      });
    }
  },
}
</script>
<style scoped>
.search-wrap {
  padding-left: 20px;
}
.search-wrap label {
  margin-right: 10px;
}
.btn {
  height: 26px;
  line-height: 26px;
  text-align: center;
  color: #fff;
  display: inline-block;
  background-color: #18a689;
  border-radius: 5px;
  padding: 5px;
  min-width: 54px;
  margin: 20px 0 20px 20px;
  cursor: pointer;
}
.btn i {
  margin-right: 2px;
}
</style>

<style lang='less'>
.projectManage-search {
  .search-wrap {
    .el-input__inner {
      border-right: 0;
    }
    .el-input-group__append .el-button {
      background: #1ab394;
      color: #fff;
      border: 1px solid #1ab394;
    }
  }
}
</style>
